# Python 2.6.4
# Project Euler, Problem 165
# Copyright 2010 Talha Zaman

def blum():
    s = 290797
    while 1:
        s = (s**2)%50515093
        yield int(s%500)

def gcd(n,m):
    if n < m: n, m = m, n
    while (n%m): n, m = m, n%m
    return m

def lowest(n,m):
    g = gcd(n,m)
    return (n/g, m/g)

def isleft(p0, p1, p2):
    return (p1[0]-p0[0])*(p2[1]-p0[1]) - (p2[0]-p0[0])*(p1[1]-p0[1])

def reject(p0, p1, p2, p3):
    if min(p0[0], p1[0]) > max(p2[0], p3[0]) or \
       max(p0[0], p1[0]) < min(p2[0], p3[0]) or \
       min(p0[1], p1[1]) > max(p2[1], p3[1]) or \
       max(p0[1], p1[1]) < min(p2[1], p3[1]): return True
    return False

def intersect(p0, p1, p2, p3):
    if reject(p0, p1, p2, p3): return False
    a = isleft(p0, p1, p2)
    b = isleft(p0, p1, p3)
    if a * b >= 0: return False
    c = isleft(p2, p3, p0)
    d = isleft(p2, p3, p1)
    if c * d >= 0: return False
    return True

def intpoint(p0, p1, p2, p3):
    A1 = p1[1] - p0[1]
    B1 = p0[0] - p1[0]
    C1 = A1*p0[0] + B1*p0[1]
    A2 = p3[1] - p2[1]
    B2 = p2[0] - p3[0]
    C2 = A2*p2[0] + B2*p2[1]
    det = A1*B2 - A2*B1
    if det==0: return
    x = B2*C1 - B1*C2
    y = A1*C2 - A2*C1
    return (lowest(x, det), lowest(y, det))

def main():
    points = blum()
    lines = []
    for i in range(5000):
        lines.append([(points.next(),points.next()), (points.next(),points.next())])
    count = 0
    inters = set()
    for i in range(5000):
        for j in range(i+1, 5000):
            if intersect(lines[i][0], lines[i][1], lines[j][0], lines[j][1]):
                count += 1
                inters.add(intpoint(lines[i][0], lines[i][1], lines[j][0], lines[j][1]))
    print count
    print len(inters)
    

from time import clock
start = clock()
main()
stop = clock()
print stop - start
